#!/bin/sh

set -e

if [ "$1" = "--python" ]; then
    shift
    PYTHON="$1"
    shift
else
    PYTHON=python
fi

if [ "$1" = "--root" ]; then
    shift
    ROOT="$1"
    shift
else
    ROOT=$(dirname $PWD)
fi

if [ "$1" = "--build" ]; then
    shift
    BUILD="$1"
    shift
else
    BUILD=$PWD
fi

if [ "$1" = "--cram" ]; then
    shift
    CRAM="$1"
    shift
else
    CRAM="$ROOT/tests/cram.py"
fi

if [ "$1" = "--tests" ]; then
    shift
    TESTS="$1"
    shift
else
    TESTS=../tests
fi

export ROOT

PATH="$BUILD:$PATH" exec "$PYTHON" "$CRAM" "$@" "$TESTS"
